<!-- layouts/default.vue -->
<template>
    <div class="app-layout">
      <!-- 固定顶部导航栏 -->
      <header class="fixed-header">
        <div class="header-content">
          <!-- 左侧标签页导航 -->
          <nav class="tab-navigation">
            <a-button 
              v-for="tab in tabs" 
              :key="tab.key"
              :type="activeTab === tab.key ? 'primary' : 'text'"
              @click="switchTab(tab.key)"
              class="tab-button"
            >
              <component :is="tab.icon" />
              {{ tab.name }}
            </a-button>
          </nav>
          
          <!-- 右侧用户信息 -->
          <div class="user-section">
            <UserProfile />
          </div>
        </div>
      </header>
  
      <!-- 主要内容区域（有顶部内边距避免被导航栏遮挡） -->
      <main class="app-main">
        <div class="main-content">
          <NuxtPage />
        </div>
      </main>
    </div>
  </template>
  
  <script setup lang="ts">
  import { HomeOutlined, FileTextOutlined, DatabaseOutlined, UserOutlined ,RobotOutlined } from '@ant-design/icons-vue'
  
  // 标签页配置
  const tabs = [
    { key: 'index', name: '首页', icon: HomeOutlined },
    { key: 'logs', name: '日志', icon: FileTextOutlined },
    { key: 'ai-interaction', name: 'ai助手', icon: RobotOutlined  },
    { key: 'repository', name: '仓库', icon: DatabaseOutlined },
    { key: 'study', name: '学习', icon: DatabaseOutlined },
    { key: 'profile', name: '我的', icon: UserOutlined }
  ]
  
  const route = useRoute()
  
  // 当前激活的标签页
  const activeTab = computed(() => {
    const routeName = route.name?.toString() || 'index'
    return routeName === 'index' ? 'index' : routeName
  })
  
  // 切换标签页
  const switchTab = (tabKey: string) => {
    navigateTo(tabKey === 'index' ? '/' : `/${tabKey}`)
  }
  </script>
  
  <style scoped>
.app-layout {
  min-height: 100vh;
  /* 设置背景图 */
  background-image: url('~/assets/images/bgcar.jpg');
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  background-attachment: fixed; /* 背景固定，内容滚动 */
}

  
  /* 固定顶部导航栏 */
  .fixed-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid #e8e8e8;
    padding: 0 24px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
    height: 64px;
  }
  
  .header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: 1200px;
    margin: 0 auto;
    height: 100%;
  }
  
  .tab-navigation {
    display: flex;
    gap: 4px;
  }
  
  .tab-button {
    display: flex;
    align-items: center;
    gap: 8px;
    height: 40px;
    padding: 0 16px;
    border-radius: 6px;
    transition: all 0.3s ease;
  }
  
  .tab-button:hover {
    background-color: #f0f0f0;
  }
  
  .user-section {
    display: flex;
    align-items: center;
  }
  
  /* 主要内容区域 - 添加顶部内边距避免被导航栏遮挡 */
  .app-main {
    padding-top: 80px; /* 导航栏高度 + 额外间距 */
    padding-bottom: 24px;
    padding-left: 24px;
    padding-right: 24px;
    min-height: calc(100vh - 80px);
  }
  
  .main-content {
    max-width: 1200px;
    margin: 0 auto;
    background: white;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    min-height: 600px;
    padding: 24px;
  }
  
  /* 响应式设计 */
  @media (max-width: 768px) {
    .fixed-header {
      padding: 0 16px;
      height: auto;
      min-height: 64px;
    }
    
    .header-content {
      flex-direction: column;
      padding: 8px 0;
    }
    
    .tab-navigation {
      width: 100%;
      justify-content: space-around;
      margin-bottom: 8px;
    }
    
    .tab-button {
      flex: 1;
      justify-content: center;
      padding: 8px;
      font-size: 12px;
    }
    
    .app-main {
      padding-top: 100px; /* 移动端需要更多顶部间距 */
      padding-left: 16px;
      padding-right: 16px;
    }
    
    .main-content {
      padding: 16px;
    }
  }
  </style>